package com.fourth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.fourth.dao.UserInfoMapper;
import com.fourth.service.UserInfoService;
import com.ljx.entity.UserInfo;
import com.ljx.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author 蒋一飞
 * @adte 2023/2/27 15:30
 */
@Service
public class UserInfoServiceImpl  implements UserInfoService {
    @Resource
    private UserInfoMapper userInfoDao;

    /**
     * 获取会员信息
     * @param currentPage
     * @param pageSize
     * @return
     */
    @Override
    public Result<UserInfo> getUserInfo(Integer currentPage, Integer pageSize,  String startTime, String endTime) {

//        List<UserInfo> userInfos = userInfoDao.selectUserInfoAll(startTime, endTime);

        Page<UserInfo> objectPage = new Page<>(currentPage, pageSize);
        QueryWrapper<UserInfo> wrapper = new QueryWrapper<>();

        if(startTime!="" && endTime!=""){
            wrapper.between("createtime",startTime,endTime);
        }

        Page<UserInfo> page = userInfoDao.selectPage(objectPage, wrapper);


        return new Result(2000,"查询成功",page);
    }

    /**
     * 根据会员id修改状态
     * @param id
     * @param status
     * @return
     */
    @Override
    public Result<UserInfo> updateUserInfo(String id, Integer status) {
        int i = userInfoDao.updateUserInfoById(id, status);
        return new Result(2000,"修改成功");
    }
}
